/**********************************************************************
 *File		Name		:	mo_button.h
 *Creat		Time		:	2022/6/3
 *Program	Author		:	Bryan He（贺璧）
 *File		Discreption	:
 *
 ************************************************************************/
#ifndef MO_BUTTON_HHH__HH_
#define MO_BUTTON_HHH__HH_

#include "../mcu/mo_config.h"
#include "../mo_core/mo_heap.h"
#include "../mo_core/mo_msg.h"

typedef enum {
    VK_NULL = 0,
    MO_VK_DW,
    MO_VK_UP,
} vk_state_t;

typedef struct input_event {
    mo_vk_code_t vk_code;
    mo_btn_pattern_t btn_pattern;
    MO_EVENTS_T event;
} mo_btn_event_map_t;

typedef struct btn_timing_ {
    mo_u16 m_click_tim;
    mo_u16 lp_tim;
    mo_u16 vlp_tim;
    mo_u16 vvlp_tim;
    mo_u16 vvvlp_tim;
    mo_u16 vvvvlp_tim;
} mo_btn_timing_t;

typedef struct btn_widget {
    mo_vk_code_t vk_code;
    mo_u16 hold_cnt;
    mo_u8 click_cnt;
    vk_state_t vk_state;

} btn_widget_t;

typedef struct btn_uint {
    btn_widget_t btn_widget;
    D_LIST_ELMT_T btn_elmt;
} btn_unit_t;

typedef struct button_task {
    mo_task_data tsk;
    // mo_u8 led;
    // D_LIST_T btn_list;
    mo_u8 vk_number;
    btn_widget_t *btn_widget_set;
    mo_task client_tsk;
    mo_bool processing;
} btn_task_t;

mo_task mo_get_btn_task(void);
mo_u8 mo_btn_init(mo_task client_tsk);
mo_u8 mo_btn_register_vk_set(btn_widget_t *widget_set, mo_u8 vk_number);
void mo_send_a_vk_to_btn_task(mo_msg_id id, mo_u8 vk_code);

#endif
